package com.bzkj.basicinfo.mapper.receive;

import com.bzkj.basicinfo.domain.receive.WmsReceiveOrderDetailEntity;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * WMS收货单明细Mapper接口
 *
 *@author lixinyu
 * @date 2025-10-22
 */
public interface WmsReceiveOrderDetailMapper {

    /**
     * 查询收货单明细列表
     *
     * @param entity 收货单明细
     * @return 收货单明细集合
     */
    List<WmsReceiveOrderDetailEntity> selectReceiveDetailList(WmsReceiveOrderDetailEntity entity);

    /**
     * 根据ID查询收货单明细
     *
     * @param id 收货单明细ID
     * @return 收货单明细
     */
    WmsReceiveOrderDetailEntity selectReceiveDetailById(@Param("id") Long id);

    /**
     * 根据收货单ID查询明细列表
     *
     * @param receiveOrderId 收货单ID
     * @return 收货单明细集合
     */
    List<WmsReceiveOrderDetailEntity> selectReceiveDetailByOrderId(@Param("receiveOrderId") Long receiveOrderId);

    /**
     * 根据收货单号查询明细列表
     *
     * @param receiveOrderNo 收货单号
     * @return 收货单明细集合
     */
    List<WmsReceiveOrderDetailEntity> selectReceiveDetailByOrderNo(@Param("receiveOrderNo") String receiveOrderNo);

    /**
     * 新增收货单明细
     *
     * @param entity 收货单明细
     * @return 结果
     */
    int insertReceiveDetail(WmsReceiveOrderDetailEntity entity);

    /**
     * 批量新增收货单明细
     *
     * @param list 收货单明细列表
     * @return 结果
     */
    int insertReceiveDetailBatch(@Param("list") List<WmsReceiveOrderDetailEntity> list);

    /**
     * 修改收货单明细
     *
     * @param entity 收货单明细
     * @return 结果
     */
    int updateReceiveDetail(WmsReceiveOrderDetailEntity entity);

    /**
     * 删除收货单明细
     *
     * @param id 收货单明细ID
     * @return 结果
     */
    int deleteReceiveDetailById(@Param("id") Long id);

    /**
     * 根据收货单ID删除明细
     *
     * @param receiveOrderId 收货单ID
     * @return 结果
     */
    int deleteReceiveDetailByOrderId(@Param("receiveOrderId") Long receiveOrderId);

    /**
     * 批量删除收货单明细
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    int deleteReceiveDetailByIds(@Param("ids") Long[] ids);

    /**
     * 更新收货数量
     *
     * @param id 收货单明细ID
     * @param receivedQuantity 已收货数量
     * @param rejectedQuantity 拒收数量
     * @param batchCode 批次号
     * @param productDate 生产日期
     * @param expDate 有效期
     * @return 结果
     */
    int updateReceiveDetailQuantity(@Param("id") Long id,
                                   @Param("receivedQuantity") java.math.BigDecimal receivedQuantity,
                                   @Param("rejectedQuantity") java.math.BigDecimal rejectedQuantity,
                                   @Param("batchCode") String batchCode,
                                   @Param("productDate") String productDate,
                                   @Param("expDate") String expDate);

    /**
     * 更新明细状态
     *
     * @param id 收货单明细ID
     * @param detailStatus 明细状态
     * @param qualityStatus 质量状态
     * @return 结果
     */
    int updateDetailStatus(@Param("id") Long id,
                          @Param("detailStatus") String detailStatus,
                          @Param("qualityStatus") String qualityStatus);
}
